/*
 *  Class name: PersonJButton.java
 *  Version: 1.0
 *  Date: 4.6.2014
 */
package cz.muni.fi.pv168.addressbook.gui.components;

import cz.muni.fi.pv168.addressbook.entities.Person;
import java.util.ResourceBundle;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;

/**
 *
 * @author Michal Ďuriš
 */
public class PersonJButton extends JButton {

    private static final long serialVersionUID = 1L;

    Person person = null;

    public PersonJButton() {
        super();
        setSettings();
    }

    public PersonJButton(Action a) {
        super(a);
        setSettings();
    }

    public PersonJButton(Icon icon) {
        super(icon);
        setSettings();
    }

    public PersonJButton(String text) {
        super(text);
        setSettings();
    }

    public PersonJButton(String text, Icon icon) {
        super(text, icon);
        setSettings();
    }

    @Override
    public String getText() {
        return person == null ? "" : person.toString();
    }

    @Override
    public String toString() {
        return person == null ? "" : person.toString();
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    private void setSettings() {
    }

    public void setSettingsWithInternationalization(ResourceBundle bundle) {

        setIcon(new ImageIcon(getClass().getResource(
                "/cz/muni/fi/pv168/addressbook/resources/icons/buttons/User-icon.png"))); // NOI18N

        setToolTipText(bundle.getString("MainWindow.personButton.toolTipText")); // NOI18N

        setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);

        setMaximumSize(new java.awt.Dimension(4096, 40));
    }

}
